﻿using System.Web.Mvc;
using BookTheBook.Data;
using BookTheBook.Data.Model;

namespace BookTheBook.Web.Controllers
{
    public class ImageController : Controller
    {
        private readonly ILibraryRepository _bookRepository = new NHibernateLibraryRepository();

        [OutputCache(Duration = 3600, VaryByParam = "imageId")]
        public FileContentResult Index(int imageId)
        {
            Book book = _bookRepository.GetBookById(imageId);
            return new FileContentResult(book.Image, "image/jpeg");
        }
    }
}
